package com.android.webrtcsdkdev.net

import okhttp3.OkHttpClient
import okhttp3.logging.HttpLoggingInterceptor
import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory
import java.util.concurrent.TimeUnit

/**

 * @Author : wy

 * @Time : On 2024/10/8 15:48

 * @Description : RetrofitClient

 */
object RetrofitClient {


    private const val BASE_URL = "http://vclusters.imwork.net:43286/api/blade-paas"
   // const val IMG_URL = "$BASE_URL/image/"

    private val okHttpClient = OkHttpClient.Builder()
        .callTimeout(30, TimeUnit.SECONDS)
        .connectTimeout(30, TimeUnit.SECONDS)
        .readTimeout(30, TimeUnit.SECONDS)
        .writeTimeout(30, TimeUnit.SECONDS)
        .retryOnConnectionFailure(true)// 重连
        .followRedirects(false)// 重定向
        .addInterceptor(RequestInterceptor())
        //.addInterceptor(ResponseInterceptor())
        .addInterceptor(HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY))
        .build()

    val retrofit: Retrofit = Retrofit.Builder()
        .baseUrl(BASE_URL)
        .addConverterFactory(GsonConverterFactory.create())
        .client(okHttpClient)
        .build()
}